package cool.mtc.minghe.data.model.sys.dict.type.form;

import cool.mtc.minghe.data.entity.sys.dict.DictTypeDO;
import cool.mtc.web.model.form.LongIdFormSupport;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import javax.validation.constraints.NotBlank;

/**
 * @author 明河
 */
@Schema(description = "表单")
@Data
public class DictTypeForm implements LongIdFormSupport {
    
    @Schema(description = "ID")
    private Long dictTypeId;

    @Schema(description = "编码")
    private String code;

    @Schema(description = "名称")
    @NotBlank(message = "dict_type.name.required")
    private String name;

    @Schema(description = "排序")
    private Integer orderIndex;

    @Schema(description = "描述")
    private String description;

    @Override
    public Long getId() {
        return dictTypeId;
    }

    public DictTypeDO transToDO() {
        DictTypeDO dictTypeDO = new DictTypeDO();
        this.updateDO(dictTypeDO);
        return dictTypeDO;
    }

    public void updateDO(DictTypeDO dictTypeDO) {
        BeanUtils.copyProperties(this, dictTypeDO);
    }
}
